Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(tracing): customizable tasks sampler #1184

Merged
merged 3 commits into from
Sep 17, 2024
Merged

Conversation

plyr4
Copy link
Contributor

@plyr4 plyr4 commented Sep 16, 2024

support for customizing the tracing sampler on a per-task basis.

{
    "task-name": {
        "active": bool
    }
}

a task is basically the "span name" based on the work being performed.
a task can be an API endpoint interaction, a gorm query, etc. see: https://opentelemetry.io/docs/specs/otel/trace/api/#span

if a task is not represented in the configuration file then the task will be treated normally, with tracing enabled.

consider the following example configuration files:

Example 1

this will enable all tracing.

{}

Example 2

this will enable all tracing except for the /health endpoint.

{
    "/health": {
        "active": false
    }
}

Example 3

{
    "/health": {
        "active": false
    },
    "/api/v1/deployments/:org/:repo": {
        "active": false
    },
    "/api/v1/:worker": {
        "active": true
    },
    "gorm.query": {
        "active": false
    }
}

/health with active: false will disable tracing on /health.

/api/v1/deployments/:org/:repo with active: false will disable tracing on /api/v1/deployments/:org/:repo for ALL :org and :repo parameters.

/api/v1/:worker with active: true will do nothing at this point, because any tasks that are not present in the configuration file will automatically be sampled normally.
for now this is slightly confusing, but in the future there will be more configuration fields that will determine how an active: true task is sampled.

gorm.query with active: false would disable tracing for raw gorm queries. this is meant to show that the config applies to all trace tasks and not just API/HTTP endpoints.

all other tasks will be sampled as normal using the parent rate limit sampler! this includes all api endpoints and gorm queries.

Potential Enhancements

planning future enhancements like per-task ratio-sampling and per-endpoint method restrictions.

consider the following stretch goal configuration file:

{
    "/health": {
        "active": false
    },
    "/api/v1/deployments/:org/:repo": {
        "active": true,
        "ratio": 0.3, // record only 30% 
        "methods": [ "get", "put" ], // record particular methods
        "query_parameters": [ "event=push" ] // record particular queries
    },

@plyr4 plyr4 requested a review from a team as a code owner September 16, 2024 16:07
Copy link

codecov bot commented Sep 17, 2024

Codecov Report

Attention: Patch coverage is 38.88889% with 11 lines in your changes missing coverage. Please review.

Project coverage is 53.05%. Comparing base (ddee444) to head (bc7cdf3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tracing/config.go 0.00% 9 Missing ⚠️
tracing/sampler.go 77.77% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1184      +/-   ##
==========================================
- Coverage   53.06%   53.05%   -0.02%     
==========================================
  Files         559      559              
  Lines       19722    19740      +18     
==========================================
+ Hits        10466    10473       +7     
- Misses       8688     8699      +11     
  Partials      568      568              
Files with missing lines Coverage Δ
tracing/sampler.go 21.87% <77.77%> (+21.87%) ⬆️
tracing/config.go 0.00% <0.00%> (ø)

@plyr4 plyr4 merged commit 809af2a into main Sep 17, 2024
11 of 13 checks passed
@plyr4 plyr4 deleted the enhance/tracing-paths branch September 17, 2024 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants